home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / g__~1 / gplibo17.zoo / g++-include / limits.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-13  |  8.2 KB  |  293 lines

  1. /*
  2.  *    LIMITS.H
  3.  *    see ansi draft sec 4.1.3 and 2.2.4.2
  4.  */
  5.  
  6. #ifndef    _LIMITS_H
  7. #define    _LIMITS_H
  8.  
  9. #ifndef _COMPILER_H
  10. #include <compiler.h>
  11. #endif
  12.  
  13. #ifndef __MINT__
  14. #define    PATHSIZE    (128)        /* maximum pathname length */
  15. #define    BITSPERBYTE    8
  16. #endif
  17.  
  18.  
  19. #define CHAR_BIT 8
  20.  
  21. #define SCHAR_MAX 127
  22. #define SCHAR_MIN (-128)
  23. #define UCHAR_MAX 255
  24.  
  25. #ifdef __CHAR_UNSIGNED__
  26. #define CHAR_MAX UCHAR_MAX
  27. #define CHAR_MIN 0
  28. #else
  29. #define CHAR_MAX SCHAR_MAX
  30. #define CHAR_MIN SCHAR_MIN
  31. #endif
  32.  
  33. #define SHRT_MAX 32767
  34. #define SHRT_MIN (-32768)
  35. #define LONG_MAX 2147483647L
  36. #define LONG_MIN (-LONG_MAX-1) /* this fixes the float cast problem ! */
  37. #define USHRT_MAX 65535U
  38. #define ULONG_MAX 4294967295UL
  39.  
  40. #ifdef __MSHORT__ /* 16 bit ints */
  41. #define INT_MAX SHRT_MAX
  42. #define INT_MIN SHRT_MIN
  43. #define UINT_MAX USHRT_MAX
  44.  
  45. #else /* 32 bit ints */
  46.  
  47. #define INT_MAX 2147483647
  48. #define INT_MIN (-INT_MAX-1) /* this fixes the float cast problem ! */
  49. #define UINT_MAX 4294967295U
  50.  
  51. #endif /* __MSHORT__ */
  52.  
  53. #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
  54. /* Minimum and maximum values a `signed long long int' can hold.  */
  55. #define LONG_LONG_MAX 9223372036854775807LL
  56. #define LONG_LONG_MIN (-LONG_LONG_MAX-1)
  57.  
  58. /* Maximum value an `unsigned long long int' can hold.  (Minimum is 0).  */
  59. #define ULONG_LONG_MAX 18446744073709551615ULL
  60.  
  61. #endif /* __GNUC__ && !__STRICT_ANSI__ */
  62.  
  63. #define MB_LEN_MAX    1    /* max. number of bytes in a multibyte character */
  64.  
  65. /*
  66.  * POSIX-specific stuff; see 1003.1 sect. 2.9
  67.  *
  68.  * Note that the library is *not* POSIX compliant; hence
  69.  * the illegally small values for some constants (e.g. _POSIX_LINK_MAX)
  70.  */
  71.  
  72. #define _POSIX_ARG_MAX        4096
  73. #define _POSIX_CHILD_MAX    6
  74. #define _POSIX_LINK_MAX        8
  75. #define _POSIX_MAX_CANON    64    /* <- NON-CONFORMING */
  76. #define _POSIX_MAX_INPUT    64    /* <- NON-CONFORMING */
  77. #define _POSIX_NAME_MAX        14
  78. #define _POSIX_NGROUPS_MAX    0
  79. #define _POSIX_OPEN_MAX        16
  80. #define _POSIX_PATH_MAX        128    /* <- NON-CONFORMING */
  81. #define _POSIX_PIPE_BUF        512
  82.  
  83. #ifndef __STRICT_ANSI__
  84.  
  85. #define NGROUPS_MAX        _POSIX_NGROUPS_MAX
  86. #if 0
  87. /* both of these are actually limited by available memory */
  88. #define ARG_MAX            32767
  89. #define CHILD_MAX        16
  90. #endif
  91.  
  92. #define OPEN_MAX        20
  93. #ifdef __MINT__
  94. # define LINK_MAX        32767
  95. #else
  96. # define LINK_MAX        1
  97. #endif
  98.  
  99. #define MAX_CANON        _POSIX_MAX_CANON
  100. #define MAX_INPUT        _POSIX_MAX_INPUT
  101. #define NAME_MAX        31
  102.         /* actually, MiNT file systems _could_ support more */
  103.  
  104. /* _LIB_NAME_MAX longest name supported in the library
  105.  *  before you change this, please look at stat.c, symdir.c, dirent.[ch],
  106.  *  unx2dos.c.
  107.  *  for the TOS library, this must be atleast 32 to maintain backwards
  108.  *  compatibility.
  109.  */
  110. #ifndef __MINT__
  111. #  define _LIB_NAME_MAX        32 /* CAUTION: dont make this any smaller */
  112. #else
  113. #  define _LIB_NAME_MAX        NAME_MAX
  114. #endif
  115.  
  116. #define PATH_MAX        _POSIX_PATH_MAX
  117. #define PIPE_BUF        _POSIX_PIPE_BUF
  118.  
  119. #endif /* __STRICT_ANSI__ */
  120.  
  121.  
  122. #ifndef _values_h
  123. #define _values_h 1
  124.  
  125. #define BITSPERBYTE 8
  126. #define BITS(type)  (BITSPERBYTE * (int)sizeof(type))
  127.  
  128. #define CHARBITS    BITS(char)
  129. #define SHORTBITS   BITS(short)
  130. #define INTBITS     BITS(int)
  131. #define LONGBITS    BITS(long)
  132. #define PTRBITS     BITS(char*)
  133. #define DOUBLEBITS  BITS(double)
  134. #define FLOATBITS   BITS(float)
  135.  
  136. #define MINSHORT    ((short)(1 << (SHORTBITS - 1)))
  137. #define MININT      (1 << (INTBITS - 1))
  138. #define MINLONG     (1L << (LONGBITS - 1))
  139.  
  140. #define MAXSHORT    ((short)~MINSHORT)
  141. #define MAXINT      (~MININT)
  142. #define MAXLONG     (~MINLONG)
  143.  
  144. #define HIBITS    MINSHORT
  145. #define HIBITL    MINLONG
  146.  
  147. #if defined(sun) || defined(hp300) || defined(hpux) || defined(masscomp) || defined(sgi)
  148. #ifdef masscomp
  149. #define MAXDOUBLE                            \
  150. ({                                    \
  151.   double maxdouble_val;                            \
  152.                                     \
  153.   __asm ("fmove%.d #0x7fefffffffffffff,%0"    /* Max double */    \
  154.      : "=f" (maxdouble_val)                        \
  155.      : /* no inputs */);                        \
  156.   maxdouble_val;                            \
  157. })
  158. #define MAXFLOAT ((float) 3.40e+38)
  159. #else
  160. #define MAXDOUBLE   1.79769313486231470e+308
  161. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  162. #endif
  163. #define MINDOUBLE   4.94065645841246544e-324
  164. #define MINFLOAT    ((float)1.40129846432481707e-45)
  165. #define _IEEE       1
  166. #define _DEXPLEN    11
  167. #define _FEXPLEN    8
  168. #define _HIDDENBIT  1
  169. #define DMINEXP     (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
  170. #define FMINEXP     (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
  171. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  172. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  173.  
  174. #elif defined(sony) 
  175. #define MAXDOUBLE   1.79769313486231470e+308
  176. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  177. #define MINDOUBLE   2.2250738585072010e-308
  178. #define MINFLOAT    ((float)1.17549435e-38)
  179. #define _IEEE       1
  180. #define _DEXPLEN    11
  181. #define _FEXPLEN    8
  182. #define _HIDDENBIT  1
  183. #define DMINEXP     (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
  184. #define FMINEXP     (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
  185. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  186. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  187.  
  188. #elif defined(sequent)
  189. extern double _maxdouble, _mindouble;
  190. extern float _maxfloat, _minfloat;
  191. #define MAXDOUBLE    _maxdouble
  192. #define MAXFLOAT    _maxfloat
  193. #define MINDOUBLE    _mindouble
  194. #define MINFLOAT    _minfloat
  195. #define _IEEE       1
  196. #define _DEXPLEN    11
  197. #define _FEXPLEN    8
  198. #define _HIDDENBIT  1
  199. #define DMINEXP     (-(DMAXEXP - 3))
  200. #define FMINEXP     (-(FMAXEXP - 3))
  201. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  202. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  203.  
  204. #elif defined(i386)
  205. #define MAXDOUBLE   1.79769313486231570e+308
  206. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  207. #define MINDOUBLE   2.22507385850720140e-308
  208. #define MINFLOAT    ((float)1.17549435082228750e-38)
  209. #define _IEEE       0
  210. #define _DEXPLEN    11
  211. #define _FEXPLEN    8
  212. #define _HIDDENBIT  1
  213. #define DMINEXP     (-DMAXEXP)
  214. #define FMINEXP     (-FMAXEXP)
  215. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  216. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  217.  
  218. /* from Andrew Klossner <andrew%frip.wv.tek.com@relay.cs.net> */
  219. #elif defined(m88k)
  220.     /* These are "good" guesses ...
  221.        I'll figure out the true mins and maxes later, at the time I find
  222.        out the mins and maxes that the compiler can tokenize. */
  223. #define MAXDOUBLE   1.79769313486231e+308
  224. #define MAXFLOAT    ((float)3.40282346638528e+38)
  225. #define MINDOUBLE   2.22507385850720e-308
  226. #define MINFLOAT    ((float)1.17549435082228e-38)
  227. #define _IEEE       1
  228. #define _DEXPLEN    11
  229. #define _FEXPLEN    8
  230. #define _HIDDENBIT  1
  231. #define DMINEXP     (1-DMAXEXP)
  232. #define FMINEXP     (1-FMAXEXP)
  233. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  234. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  235.  
  236. #elif defined(convex)
  237. #define MAXDOUBLE   8.9884656743115785e+306
  238. #define MAXFLOAT    ((float) 1.70141173e+38)
  239. #define MINDOUBLE   5.5626846462680035e-308
  240. #define MINFLOAT    ((float) 2.93873588e-39)
  241. #define _IEEE       0
  242. #define _DEXPLEN    11
  243. #define _FEXPLEN    8
  244. #define _HIDDENBIT  1
  245. #define DMINEXP     (-DMAXEXP)
  246. #define FMINEXP     (-FMAXEXP)
  247. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  248. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  249.  
  250. #elif defined(atarist) 
  251. #define MAXDOUBLE   1.7976931348623158e+308
  252. #define MAXFLOAT    ((float)3.40282347e+38)
  253. #define MINDOUBLE   2.2250738585072014e-308
  254. #define MINFLOAT    ((float)1.17549435e-38)
  255. #define _IEEE       1
  256. #define _DEXPLEN    11
  257. #define _FEXPLEN    8
  258. #define _HIDDENBIT  1
  259. #define DMINEXP     (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
  260. #define FMINEXP     (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
  261. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  262. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  263.  
  264. // #elif defined(vax)
  265. // use vax versions by default -- they seem to be the most conservative
  266. #else 
  267.  
  268. #define MAXDOUBLE   1.701411834604692293e+38
  269. #define MINDOUBLE   (2.938735877055718770e-39)
  270.  
  271. #define MAXFLOAT    1.7014117331926443e+38
  272. #define MINFLOAT    2.9387358770557188e-39
  273.  
  274. #define _IEEE       0
  275. #define _DEXPLEN    8
  276. #define _FEXPLEN    8
  277. #define _HIDDENBIT  1
  278. #define DMINEXP     (-DMAXEXP)
  279. #define FMINEXP     (-FMAXEXP)
  280. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  281. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  282. #endif
  283.  
  284. #define DSIGNIF     (DOUBLEBITS - _DEXPLEN + _HIDDENBIT - 1)
  285. #define FSIGNIF     (FLOATBITS  - _FEXPLEN + _HIDDENBIT - 1)
  286. #define DMAXPOWTWO  ((double)(1L << LONGBITS -2)*(1L << DSIGNIF - LONGBITS +1))
  287. #define FMAXPOWTWO  ((float)(1L << FSIGNIF - 1))
  288.  
  289. #endif
  290.  
  291.  
  292. #endif /* _LIMITS_H */
  293.